import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入登录页
import Login from '@/views/login/login.vue'
// 首页
import Home from '@/views/home/home.vue'
// 主页
import Index from '@/views/home/index.vue'
// 搜索
import Search from '@/views/home/search.vue'
// 视频
import Video from '@/views/home/video.vue'
// 我的
import My from '@/views/home/my.vue'
// 搜索结果
import searchResult from '@/views/searchResult/searchResult.vue'
// 文章详情
import Detail from '../views/detail/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/checkLogin',
    component: Login
  },
  {
    path: '/home',
    component: Home,
    // 重定向
    redirect: '/index',
    children: [
      {
        path: '/index',
        component: Index
      },
      {
        path: '/search',
        component: Search
      },
      {
        path: '/tv',
        component: Video
      },
      {
        path: '/my',
        component: My
      }
    ]
  },
  {
    path: '/searchResult/:key',
    component: searchResult
  },
  {
    path: '/detail/:artid',
    component: Detail
  },
  {
    path: '/info',
    component: () => import('@/views/info/info.vue')
  },
  {
    // 异步组件
    path: '/zhi',
    component: () => import('@/views/zhi/zhi.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
